import javax.swing.*;
import java.awt.*;

public class eg9_4 {
    public static void main(String[] args) {
        GridLayotFrame frame3 = new GridLayotFrame();
    }

    public static class GridLayotFrame extends JFrame {

        private JButton button1;
        private JButton button2;
        private JButton button3;
        private JButton button4;
        private JButton button5;
        private JPanel  panel1;

        private JButton button6;
        private JButton button7;
        private JButton button8;
        public GridLayotFrame(){
            button1 =new JButton("按钮1");
            button2 =new JButton("按钮2");
            button3 =new JButton("按钮3");
            button4 =new JButton("按钮4");
            button5 =new JButton("按钮5");
            panel1=new JPanel();
            button6 =new JButton("按钮6");
            button7 =new JButton("按钮7");
            button8 =new JButton("按钮8");

            this.setLayout(new GridLayout(2,3));
            this.add(button1);
            this.add(button2);
            this.add(button3);
            this.add(button4);
            this.add(button5);
            this.add(panel1);

            panel1.setLayout(new GridLayout(3,1));
            panel1.add(button6);
            panel1.add(button7);
            panel1.add(button8);
            this.setTitle("GideLayout网式布局");
            this.setSize(600,400);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setVisible(true);
        }
    }
}
